
import ProductModel from "@/model/Product"

export default class Product{
    /**
     * name
     */
    public async getProductList(ctx,next) {
        try {
            const productList = await ProductModel.findAll();
        ctx.body={
            code: 200,
            message: "查询成功",
            data: productList
        }
        } catch (error) {
         ctx.body={
            code: 400,
            message: "查询失败"
         }   
        }
    }
    public async getProductDetails(ctx,next) {
        try {
            const {product_id} = ctx.request.query;
            const productDetails = await ProductModel.findOne({
                where:{
                    product_id:product_id
                }
            });
        ctx.body={
            code: 200,
            message: "查询成功",
            data: productDetails
        }
        } catch (error) {
         ctx.body={
            code: 400,
            message: "查询失败"
         }   
        }
    }
}